﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                        xmlns:my="clr-namespace:Brjnk.GpxExplorer.WPF"
    xmlns:controls="clr-namespace:Brjnk.GpxExplorer.UI.Controls">
    <Style TargetType="{x:Type controls:MapRotationPicker}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type controls:MapRotationPicker}">
                    <Border Background="Transparent"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <Border.Resources>
                            <my:InvertConverter x:Key="InvertConverter" />
                        </Border.Resources>

                        <Grid RenderTransformOrigin="0.5,0.5">
                            <Grid.RenderTransform>
                                <RotateTransform Angle="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=Angle}" />
                            </Grid.RenderTransform>
                            <Ellipse>
                                <Ellipse.Fill>
                                    <RadialGradientBrush Center="0.5,0.5">
                                        <GradientStop Offset="0" Color="White" />
                                        <GradientStop Offset="1" Color="LightBlue" />
                                    </RadialGradientBrush>
                                </Ellipse.Fill>
                            </Ellipse>

                            <TextBlock Margin="5" VerticalAlignment="Top" FontWeight="Bold" HorizontalAlignment="Center" Text="N" RenderTransformOrigin="0.5,0.5">
                              <TextBlock.RenderTransform>
                                  <RotateTransform Angle="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=Angle, Converter={StaticResource  ResourceKey=InvertConverter}}" />
                              </TextBlock.RenderTransform>
                            </TextBlock>
                            <TextBlock Margin="5" VerticalAlignment="Bottom" FontWeight="Bold" HorizontalAlignment="Center" Text="S" RenderTransformOrigin="0.5,0.5">
                              <TextBlock.RenderTransform>
                                  <RotateTransform Angle="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=Angle, Converter={StaticResource ResourceKey=InvertConverter}}" />
                              </TextBlock.RenderTransform>
                            </TextBlock>
                            <TextBlock Margin="5" VerticalAlignment="Center" FontWeight="Bold" HorizontalAlignment="Left" Text="W" RenderTransformOrigin="0.5,0.5">
                              <TextBlock.RenderTransform>
                                  <RotateTransform Angle="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=Angle, Converter={StaticResource ResourceKey=InvertConverter}}" />
                              </TextBlock.RenderTransform>
                            </TextBlock>
                            <TextBlock Margin="5"  VerticalAlignment="Center" FontWeight="Bold" HorizontalAlignment="Right" Text="E" RenderTransformOrigin="0.5,0.5">
                              <TextBlock.RenderTransform>
                                  <RotateTransform Angle="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=Angle, Converter={StaticResource ResourceKey=InvertConverter}}" />
                              </TextBlock.RenderTransform>
                            </TextBlock>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>